import requests

import app


class Depapi:
    def __init__(self, token):
        self.url_all = app.BASE_HOST + "/api/company/department"
        self.url_one = app.BASE_HOST + "/api/company/department/"
        self.header_dict = {"Authorization": token}

    def add_dep(self, json_dict):
        return requests.post(url=self.url_all, headers=self.header_dict, json=json_dict)

    def get_dep(self, id):
        return requests.get(url=self.url_one + str(id), headers=self.header_dict)

    def update(self, id, json_dict):
        return requests.put(url=self.url_one + str(id), headers=self.header_dict, json=json_dict)

    def del_dep(self, id):
        return requests.delete(url=self.url_one + str(id), headers=self.header_dict)
